//
// Created by 王书哲 on 25-3-15.
//
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LINE 81

void ToUpper(char *);
int PunctCount(const char *);
int main(void)
{
    char line[81];
    int count;

    printf("Enter a line of text:\n");
    fgets(line, LINE, stdin);
    char * find = strchr(line, '\n');
    if (find)
        *find = '\0';
    ToUpper(line);
    puts(line);
    count = PunctCount(line);
    printf("That line has %d punctuation character(s).\n", count);

    return 0;
}

void ToUpper(char *str)
{
    while (*str)
    {
        *str = toupper(*str);
        str++;
    }
}

int PunctCount(const char *str){
    int count = 0;
    while(*str)
    {
        if (ispunct(*str))
        {
            count++;
        }
        str++;
    }
    return count;
}